//
// SoapTrace.Net - A soap message monitoring utility. 
//
// Copyright (C) 2005 Matthew Ward
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
//
// Matthew Ward (mrward@users.sourceforge.net)

using System;
using WinPcap;

namespace SoapTrace.Core.Diagnostics
{
	/// <summary>
	/// A single entry in the <see cref="PacketLogFile"/>.
	/// </summary>
	public class PacketLogEntry
	{
		/// <summary>
		/// Ethernet packet entry type.
		/// </summary>
		public static readonly string Ethernet = "Ethernet";
		
		/// <summary>
		/// IP packet entry type
		/// </summary>
		public static readonly string IP = "IP";
		
		/// <summary>
		/// The packet's arrival time.
		/// </summary>
		private DateTime m_PacketReceivedTime;
		
		/// <summary>
		/// The IP address of the remote server that was set
		/// as a filter when the packet was received.
		/// </summary>
		private string m_RemoteServerFilter = String.Empty;
		
		/// <summary>
		/// The port the remote server is listening on.
		/// </summary>
		private int m_RemoteServerPortFilter;
		
		/// <summary>
		/// A data packet.
		/// </summary>
		private Packet m_Packet;
		
		/// <summary>
		/// The packet type.
		/// </summary>
		private string m_PacketType = String.Empty;
		
		/// <summary>
		/// Creates a new instance of the <see cref="PacketLogEntry"/>.
		/// </summary>
		/// <param name="remoteServer">The destination IP address of the 
		/// packet filter that was being used when this packet was received.</param>
		/// <param name="port">The port number of the packet filter that was 
		/// being used when this packet was received</param>
		/// <param name="timeReceived">The time the packet was received.</param>
		/// <param name="packet">A data packet.</param>
		/// <param name="packetType">The type of the packet.</param>
		public PacketLogEntry( string remoteServer, int port, DateTime timeReceived, Packet packet, string packetType )
		{
			m_PacketReceivedTime = timeReceived;
			m_RemoteServerFilter = remoteServer;
			m_RemoteServerPortFilter = port;
			m_Packet = packet;
			m_PacketType = packetType;
		}
		
		/// <summary>
		/// Gets the time the packet was received by the application.
		/// </summary>
		public DateTime PacketReceivedTime
		{
			get
			{
				return m_PacketReceivedTime;
			}
		}
		
		/// <summary>
		/// Gets the IP address of the server set in the filter when
		/// the packet was received.
		/// </summary>
		public string RemoteServerFilter
		{
			get
			{
				return m_RemoteServerFilter;
			}
		}
		
		/// <summary>
		/// Gets the port of the server set in the filter when
		/// the packet was received.
		/// </summary>
		public int RemoteServerPortFilter
		{
			get
			{
				return m_RemoteServerPortFilter;
			}
		}	
		
		/// <summary>
		/// A data packet.
		/// </summary>
		public Packet Packet
		{
			get
			{
				return m_Packet;
			}
			
			set
			{
				m_Packet = value;
			}
		}
		
		/// <summary>
		/// The packet type.
		/// </summary>
		public string PacketType
		{
			get
			{
				return m_PacketType;
			}
		}		
	}
}
